<?php

namespace addons\qingdong\model;

use think\Model;
use traits\model\SoftDelete;

/**
 *员工外勤签到
 */
class StaffSignIn Extends Model {
	use SoftDelete;
    // 表名,不含前缀
    protected $name = 'qingdong_staff_sign_in';
	// 开启自动写入时间戳字段
	protected $autoWriteTimestamp = 'int';
	// 定义时间戳字段名
	protected $createTime = 'createtime';
	protected $updateTime = 'updatetime';
	protected $deleteTime = 'deletetime';


	public function getFileIdsAttr($value){
		$files      = explode(',',$value);
		$files_v = [];
		foreach ($files as $fid) {
			if($fid){
				$files_v[] = cdnurl(File::getUrl($fid), true);
			}
		}
		return $files_v;
	}

	//获取创建时间
	public function getCreatetimeAttr($value) {
		return date('Y-m-d H:i:s', $value);
	}

	//员工
	public function staff(){
		return $this->belongsTo(Staff::class,'staff_id','id')->field('id,name,img');
	}

	//客户
	public function customer(){
		return $this->belongsTo(Customer::class,'customer_id','id')->field('id,name');
	}

}
